module.exports = {
	isPhone:(phone) => {
		const regx = /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/;
		if(!regx.test(phone)) return false;
		return true;
	},
	isMobilePhone:(phone) => {
	    const regx =/^[1][3,4,5,7,8][0-9]{9}$/;
		if ((!regx.test(value)) && value != '') return false;
		return true;
	},
	isEmail:(email) => {
		const regx =/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
		if(!regx.test(email)) return false;
		return true;
	},
	isNumber:(domain) => {
		const regx = /^[0-9]*$/
		if(!regx.test(domain)) return false;
		return true;
		
	},
	/**
	 * 匹配integer
	 */
	isInteger:(str) => {
	    if(str==null||str=="") return false;
	    var result=str.match(/^[-\+]?\d+$/);
	    if(result==null)return false;
	    return true;
	},
	/**
	 * 匹配qq
	 */
	isQq:(str) => {
	    if(str==null||str=="") return false;
	    var result=str.match(/^[1-9]\d{4,12}$/);
	    if(result==null)return false;
	    return true;
	},
	isZhCN:(str) => {
		const regx = /^[\u4e00-\u9fa5]{0,}$/;
		if(!regx.test(str)) return false;
		return true;
	},
	isId:(id,callback) => {
		const regx = /^\d{15}|\d{18}$/;
		if(!regx.test(id)) return false;
		return true;
	},
	isIp:(id) => {
		const reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
		if ((!reg.test(value)) && value != '') return false;
		return true;
	},
	/**
	 * 判断是否包含中英文特殊字符，除英文"-_"字符外
	 */
	isContainsSpecialChar:(str) => {
	    if(str==null||str=="") return false;
	    var regx = RegExp(/[(\ )(\`)(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\()(\))(\+)(\=)(\|)(\{)(\})(\')(\:)(\;)(\')(',)(\[)(\])(\.)(\<)(\>)(\/)(\?)(\~)(\！)(\@)(\#)(\￥)(\%)(\…)(\&)(\*)(\（)(\）)(\—)(\+)(\|)(\{)(\})(\【)(\】)(\‘)(\；)(\：)(\”)(\“)(\’)(\。)(\，)(\、)(\？)]+/);   
	    return regx.test(str);    
	},
	/**
	 * 过滤中英文特殊字符，除英文"-_"字符外
	 */
	stringFilter: (str) => {
	    var pattern = new RegExp("[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]");
	    var rs = "";
	    for (var i = 0; i < str.length; i++) {
	        rs = rs + str.substr(i, 1).replace(pattern, '');
	    }
	    return rs;
	},
	/**
	 * 字符验证，只能包含中文、英文、数字、下划线等字符。
	 */
	stringCheck:(str) => {
	    if(str==null||str=="") return false;
	    var result=str.match(/^[a-zA-Z0-9\u4e00-\u9fa5-_]+$/);
	    if(result==null)return false;
	    return true;
	},
	/**
	 * 匹配中文(包括汉字和字符)
	 */
	isChineseChar:(str) => {
	    if(str==null||str=="") return false;
	    var result=str.match(/^[\u0391-\uFFE5]+$/);
	    if(result==null)return false;
	    return true;
	},
	/**
	 * 匹配汉字
	 */
	isChinese: (str) => {
	    if(str==null||str=="") return false;
	    var result=str.match(/^[\u4e00-\u9fa5]+$/);
	    if(result==null)return false;
	    return true;
	},
	/**
	 * 判断是否为合法字符(a-zA-Z0-9-_)
	 */
	isRightfulString: (str)=> {
	    if(str==null||str=="") return false;
	    var result=str.match(/^[A-Za-z0-9_-]+$/);
	    if(result==null)return false;
	    return true;
	},
	/**
	 * 匹配english
	 */
	isEnglish: (str)=> {
	    if(str==null||str=="") return false;
	    var result=str.match(/^[A-Za-z]+$/);
	    if(result==null)return false;
	    return true;
	},
	/**
	 * 匹配money
	 */
	isMoney: (str) => {
	    if(str==null||str=="") return false;
	    var result=str.match(/^(([1-9]\d*)|(([0-9]{1}|[1-9]+)\.[0-9]{1,2}))$/);
	    if(result==null)return false;
	    return true;
	} 
}